import numpy as np
import matplotlib.pyplot as plt

def plot_array(array):
    # 绘制一维数组
    plt.plot(array)
    plt.xlabel('Index')
    plt.ylabel('Value')
    plt.title('Array Plot')
    plt.show()

def find_largest_deviation(array, n=3):
    # 找到偏离0较大的前n个值及其索引
    absolute_values = np.abs(array)
    indices = np.argsort(absolute_values)[-n:]
    values = array[indices]
    return indices, values

# 示例数组
array = np.array([0.1, -0.2, 0.3, -0.4, 0.5, -0.6, 0.7, -0.8, 0.9, -1.0])

# 绘制数组
plot_array(array)

# 找到偏离0较大的三个值及其索引
indices, values = find_largest_deviation(array)

# 输出结果
print("Indices with largest deviations:", indices)
print("Values with largest deviations:", values)